<!DOCTYPE html>
<html>

<head>
    <title>表单示例</title>
    <style>
        .msg-error {
            color: #dc3545;
        }

        /* Bootstrap 红色 */
        .msg-success {
            color: #28a745;
        }

        /* Bootstrap 绿色 */
    </style>
</head>

<body>
    <h2>用户注册</h2>

    <!-- 显示消息 -->
    {% if messages %}
    {% for message in messages %}
    <p class="msg-{{ message.tags }}">
        {{ message }}
    </p>
    {% endfor %}
    {% endif %}

    <form method="post">
        {% csrf_token %} <!-- 必须包含 CSRF 令牌 -->
        <p>
            <label for="username">用户名:</label>
            <input type="text" name="username" required>
        </p>
        <p>
            <label for="email">邮箱:</label>
            <input type="email" name="email" required>
        </p>
        <button type="submit">提交</button>
    </form>
</body>

</html>